<?php 
/**
 * @version        $Id$
 * @author         master@xuewl.com
 * @copyright      Copyright (c) 2007 - 2014, Chongqing xuewl Information Technology Co., Ltd.
 * @link           http://www.xuewl.com
**/
namespace Member\Controller;
use \Member\Controller\InitController;
class CaptchaController extends InitController {
	
	public function _initialize() {
		parent::_initialize();
		$this->account = D('DamaAccount');
		$this->log = D('DamaLog');
		$this->dama = D('Dama');
		$this->db = D('Member');
	}

	
	public function dama_info() {
    	$pagecurr = max(1,I('page',0,'intval'));
		$pagesize = 10;

		$count = $this->account->where(array('uid'=>$this->userid))->count();
		$account=$this->account->where(array('uid'=>$this->userid))->page($pagecurr,$pagesize)->select();
			if ($account){
					$dama_ids=array();
					foreach ($account as $v){
						$dama_ids[]=$v['aid'];
						
					}
					$dama_id=array_unique($dama_ids);
					$conditions=array();
					$conditions['id']=array("IN",$dama_id);
					$dama_info=$this->dama->where($conditions)->select();
					foreach ($dama_info as $key  => $dama){
							for ($i=0;$i<count($dama_info);$i++){
							   if ($dama['id']== $account[$i]['aid']){
							       $account[$i]['title']=$dama['title'];
							       $account[$i]['is_changeip']=$dama['is_changeip'];
							       $account[$i]['source']=$dama['source'];
							       $account[$i]['price']=$dama['price'];
							   }
							}
					
					}
					 
					$log_ids=array();
					$log_ids['aid']=array("IN",$dama_id);
					$log_info=$this->log->where($log_ids)->select();
				    foreach ($log_info as $key  => $log){
							for ($i=0;$i<count($log_info);$i++){
							   if ($log['account_id']== $account[$i]['id']){
							       $account[$i]['yard_num']=$log['yard_num'];
							       $account[$i]['yard_u_coin']=$log['yard_u_coin'];
							       
							   }
							}
					
					}
					
				  
				  $id=array();
				  $id['id']=array("NOT IN ",$dama_id);
				  $count=$this->dama->where($id)->count();
			}else{
			  $count=$this->dama->count();
			
			}
	    	$infos = "1";
			$SEO=seo(0,"打码信息");
			include template('code_info');;
	}
	public function dama_no(){
		$pagecurr = max(1,I('page',0,'intval'));
		$pagesize = 10;

		$user=$this->account->where(array('uid'=>$this->userid))->getField('aid',true);
		if(isset($user)){		
			$user['id'] = array("NOT IN", $user);
			$count = $this->dama->where($user)->count();
			$info = $this->dama->where($user)->page($pagecurr,$pagesize)->select();
		}else{
			$info = $this->dama->page($pagecurr,$pagesize)->select();
			$count = $this->dama->count();
		}

		

		

		$infos = "2";
		$pages = page($count,$pagesize);
		$SEO=seo(0,"打码信息");
		include template('code_info');;
	}
	
	public function game(){
		$SEO=seo(0,"试玩体验信息");
		include template('games');
	}
	
    public function detRecord(){
       $id=$_POST['tdID'];
       if (!$id){
        	return false;
       }else{
        $result=$this->account->where(array('id'=>$id))->delete();
        $arr = array();
		if($result){
			$arr = array('rs'=>1);
		}else{
			$arr = array('rs'=>0);
		}
		echo json_encode($arr);
        
       }
      
    }
	
	
	
}